<?php

namespace App\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

class BaseController extends Controller
{

    function __construct()
    {
    }

    protected function formValidate(Request $request, array $rules, &$formData = [])
    {
        $validator = Validator::make($request->input(), $rules);
        $errors = $validator -> errors() -> all();
        if ($message = $errors[0] ?? '') return $message;
        $formData = $this -> validate($request, $rules);
        return null;
    }

}